package com.huawei.boss.statemachine;

import java.util.HashMap;
import java.util.Map;

public class Event
{
    private String name;
    private Map<State, Transition> transitions = new HashMap<State, Transition>();

    public Event(String name)
    {
        this.name = name;
    }
   
    public void registerTransition(State from , State to)
    {
        assert(from != null);
        assert(to != null);
        Transition trans = new Transition(this, from, to);
        transitions.put(from, trans);
    }
   
    public State fireTransaction(State from)
    {
        Transition to = this.transitions.get(from);
       
        if(to!=null)
        {
            return to.getTo();
        }
        return null;
    }
}